var app = getApp();
var md5 = require("../../utils/md5.js");
var wxpay = require('../../utils/pay.js');
Page({
  data: {
    tabs: ["店铺配送", "到店自取"],
    payArr: ["余额支付", "微信支付"],
    tabClass: ["", ""],
    activeTab: 1,
    stv: {
      
      windowWidth: 0,
      lineWidth: 0,
      offset: 0,
      tStart: false
    },
    goodsList: [],
    is_show: false,
    isNeedLogistics: 0, // 是否需要物流信息
    allGoodsPrice: 0,
    yunPrice: 0,
    allGoodsAndYunPrice: 0,
    goodsJsonStr: "",
    orderType: "", //订单类型，购物车下单或立即支付下单，默认是购物车，
    isDikou: false,
    hasNoCoupons: true,
    coupons: [],
    youhuijine: 0, //优惠券金额
    curCoupon: null, // 当前选择使用的优惠券
    pay_type: '',
    note: '',
    isback:false,
    order_price:0,
    reduceMone: 0,
    isType: true,
    checked: false
  },
  onShow: function() {
    var that = this;
    if (that.data.isback) {
      wx.navigateBack()
    }else{
      wx.showToast({
        title: '加载中',
        icon: 'loading'
      })
      setTimeout(function () {
        wx.hideToast()
        that.setData({
          is_show: true
        })
      }, 1000)
      let {
      tabs
    } = that.data;
      var shopList = [];
      var shopCarInfoMem = wx.getStorageSync('shopCarInfo');
      console.log(shopCarInfoMem);
      var addressSelectInfo = wx.getStorageSync('addressSelectInfo');
      var addressSelectList = wx.getStorageSync('addressSelectList');
      var service = 'Order.GetAddress';
      var open_id = app.globalData.openId;
      var user_id = app.globalData.userId;
      var sign = md5.md5(open_id + service + user_id);
      var addressSelectInfo = wx.getStorageSync('addressSelectInfo');
      wx.request({
        url: app.globalData.serviceUrl + 'Order.GetAddress',
        header: {
          'Content-Type': 'json'
        },
        data: {
          open_id: open_id,
          user_id: user_id,
          sign: sign,
        },
        success: (res) => {
          var result = res.data.data;
          var newList = []
          if (result.code == 0) {
            var i = 0; var l = 0;
            for (i = 0, l = result.info.length; i < l; i++) {
              if (result.info[i].is_moren == '1') {
                console.log('地址')
                shopCarInfoMem.default_address = result.info[i];
                console.log(result.info[i].is_moren);
                console.log(result.info[i]);
                console.log(shopCarInfoMem);
                console.log('地址')
              }
            }
          } else {
            shopCarInfoMem.default_address = false;
          }
        }
      });
      var reduceMone = 0;
      var user_id = app.globalData.userId;
      var openid = app.globalData.openId;
      var shop_id = shopCarInfoMem.shop_id;
      var order_num = shopCarInfoMem.order_num;
      var product_id = 0;
      var goumai_num = 1;
      var service = 'Order.GetDiscountInfo';

      var sign = md5.md5(goumai_num + openid + order_num + product_id + service + shop_id + user_id);
      wx.request({
        url: app.globalData.serviceUrl + 'Order.GetDiscountInfo',
        header: {
          'Content-Type': 'json'
        },
        data: {
          sign: sign,
          user_id: user_id,
          openid: openid,
          product_id: product_id,
          shop_id: shop_id,
          order_num: order_num,
          goumai_num: goumai_num
        },
        success: function (res) {
          console.log(res);
          var discount = res.data.data.info.discount;
          var cost = res.data.data.info.cost;
          if (shopCarInfoMem) {
            shopCarInfoMem.dikou = discount;
            shopCarInfoMem.cost = cost;
            if (shopCarInfoMem && shopCarInfoMem.goodsList) {
              shopList = shopCarInfoMem.goodsList;
            }
            var activeTab = 1;
            if (shopCarInfoMem.is_delive) {
              activeTab = 0;
            }
            if (shopCarInfoMem.is_canhe_dis == '0') {
              shopCarInfoMem.order_price = parseFloat(shopCarInfoMem.order_price) + parseFloat(shopCarInfoMem.canhe_money);
              shopCarInfoMem.order_price = shopCarInfoMem.order_price.toFixed(2);
              shopCarInfoMem.total_price = shopCarInfoMem.order_price;
            } else {
              reduceMone = parseFloat(reduceMone) + parseFloat(shopCarInfoMem.canhe_money);
              reduceMone = reduceMone.toFixed(2);
            }
            that.setData({
              reduceMone: reduceMone,
              activeTab: activeTab
            })
            //访问配送接口计算价格
            var is_dada = 1;
            if (addressSelectInfo == false) {
              shopCarInfoMem.default_address = false;
            }
            if (addressSelectInfo) {
              shopCarInfoMem.default_address = addressSelectInfo;
            } else {
              shopCarInfoMem.default_address = false;
            }
            var res = wx.getSystemInfoSync()
            that.windowWidth = res.windowWidth;
            that.data.stv.lineWidth = that.windowWidth / that.data.tabs.length;
            that.data.stv.windowWidth = res.windowWidth;
            that.data.stv.offset = res.windowWidth * activeTab;
            that.setData({
              stv: that.data.stv,
            });
            that.tabsCount = tabs.length;
            that.setData({
              goodsList: shopList,
              buyNowInfoMem: shopCarInfoMem,
              order_price: shopCarInfoMem.order_price,
              dikou: shopCarInfoMem.dikou,
              cost: shopCarInfoMem.cost,
            })
            if (shopCarInfoMem.is_dada) {
              that.getDadafee();
              is_dada = 0;
            }else{
              //商家自配计算一下是否减免配送费
              if (shopCarInfoMem.is_peisong_dis == '0') {
                shopCarInfoMem.order_price = parseFloat(shopCarInfoMem.order_price) + parseFloat(shopCarInfoMem.delive_fee);
                shopCarInfoMem.order_price = shopCarInfoMem.order_price.toFixed(2);
                that.setData({
                  shopCarInfoMem: shopCarInfoMem,
                  order_price: shopCarInfoMem.order_price,
                })
              } else {
                reduceMone = parseFloat(reduceMone) + parseFloat(shopCarInfoMem.delive_fee);
                reduceMone = reduceMone.toFixed(2);
              }
            }
            console.log(reduceMone);
            that.setData({
              is_dada: is_dada,
              reduceMone: reduceMone,
            })
          }
        }
      })
    }
    
  },

  getDadafee: function () {
    var that = this;
    var reduceMone = that.data.reduceMone;
    var activeTab = that.data.activeTab;
    var isType = that.data.isType;
    var buyNowInfoMem = that.data.buyNowInfoMem;
    var default_address = buyNowInfoMem.default_address;
    // var addressSelectInfo = wx.getStorageSync('addressSelectInfo');
    // var default_address = '';
    // if (addressSelectInfo.contact_name != undefined) {
    //   var default_address = addressSelectInfo;
    // } else {
    //   var default_address = buyNowInfoMem.default_address;
    // }
    if (activeTab == 0 ) {
      var service = 'Order.GetNewAddress';
      var open_id = app.globalData.openId;
      var user_id = app.globalData.userId;
      var sign = md5.md5(open_id + service + user_id);
      wx.request({
        url: app.globalData.serviceUrl + 'Order.GetNewAddress',
        header: {
          'Content-Type': 'json'
        },
        data: {
          open_id: open_id,
          user_id: user_id,
          sign: sign,
        },
        success: (resa) => {
          var resulta = resa.data.data;
          var newList = []
          if (resulta.code == 0) {
            var i = 0; var l = 0;
            for (i = 0, l = resulta.info.length; i < l; i++) {
              if (resulta.info[i].is_moren == '1') {
                
                var service = 'Dada.QueryDeliverFee';
                var shop_no = buyNowInfoMem.shop_id;
                var origin_id = buyNowInfoMem.order_num;
                var city_code = buyNowInfoMem.dada_city_code;
                var cargo_price = buyNowInfoMem.order_price;
                var receiver_name = resulta.info[i].contact_name;
                var receiver_address = resulta.info[i].contact_address;
                var jingwei = resulta.info[i].contact_address_jingwei.split(",");
                var receiver_lat = jingwei[0];
                var receiver_lng = jingwei[1];
                var receiver_phone = resulta.info[i].contact_tel;

                var sign = md5.md5(cargo_price + city_code + origin_id + receiver_address + receiver_lat + receiver_lng + receiver_name + receiver_phone + service + shop_no);
                wx.request({
                  url: app.globalData.serviceUrl + service,
                  header: {
                    'Content-Type': 'json'
                  },
                  data: {
                    sign: sign,
                    shop_no: shop_no,
                    origin_id: origin_id,
                    city_code: city_code,
                    cargo_price: cargo_price,
                    receiver_name: receiver_name,
                    receiver_address: receiver_address,
                    receiver_lat: receiver_lat,
                    receiver_lng: receiver_lng,
                    receiver_phone: receiver_phone,
                  },
                  success: (res) => {
                    var result = res.data.data;
                    if (result.code == 0) {
                      buyNowInfoMem.delive_fee = result.info.fee;
                      if (isType) {
                        if (buyNowInfoMem.is_peisong_dis == '0') {
                          buyNowInfoMem.order_price = parseFloat(buyNowInfoMem.order_price) + parseFloat(result.info.fee);
                          buyNowInfoMem.order_price = buyNowInfoMem.order_price.toFixed(2);
                        } else {
                          reduceMone = parseFloat(reduceMone) + parseFloat(result.info.fee);
                          reduceMone = reduceMone.toFixed(2);
                        }
                        isType = false;
                      }
                      buyNowInfoMem.default_address.contact_address = default_address.contact_address;
                      buyNowInfoMem.default_address.contact_address_jingwei = default_address.contact_address_jingwei;
                      buyNowInfoMem.default_address.contact_menpai = default_address.contact_menpai;
                      buyNowInfoMem.default_address.contact_name = default_address.contact_name;
                      buyNowInfoMem.default_address.contact_sex = default_address.contact_sex;
                      buyNowInfoMem.default_address.contact_tel = default_address.contact_tel;
                      var order_price = buyNowInfoMem.order_price;
                      that.setData({
                        isType: isType,
                        reduceMone: reduceMone,
                        buyNowInfoMem: buyNowInfoMem,
                        deliveryNo: result.info.deliveryNo,
                        jingwei: default_address.contact_address_jingwei,
                        order_price: order_price,
                        checked: false,
                        isDikou: false
                      });
                    } else {
                      wx.showModal({
                        title: '提示',
                        content: '配送地址有误，请重新填写',
                        success: function (res) {
                          wx.navigateTo({
                            url: "/pages/select-address/index"
                          })
                        },
                        showCancel: false
                      })
                      return;
                    }
                  },
                  fail: function () {
                    //请求超时提示
                    wx.showModal({
                      title: '提示',
                      content: '网络超时',
                      showCancel: false
                    })
                    return;
                  }
                })


              }
            }
          } else {
            buyNowInfoMem.default_address = false;
          }
        }
      });
    } else {
      var buyNowInfoMem = that.data.buyNowInfoMem;
      //buyNowInfoMem.order_price = that.data.buyNowInfoMem.order_price;
       that.setData({
         order_price: that.data.buyNowInfoMem.total_price,
         buyNowInfoMem: buyNowInfoMem,
       })
    }
  },

  onLoad: function(e) {
    var that = this;
    wx.setNavigationBarTitle({
      title: wx.getStorageSync('mallName')
    })
    var mallInfo = wx.getStorageSync('mallName');
    this.setData({
      mallInfo: mallInfo
    });
    this.getlod();
    that.setData({
      isNeedLogistics: 1,
      orderType: e.orderType
    });
  },

  _updateSelectedPage(page) {
    let {
      tabs
    } = this.data;
    var res = wx.getSystemInfoSync()
    this.windowWidth = res.windowWidth;
    this.data.stv.lineWidth = this.windowWidth / this.data.tabs.length;
    this.data.stv.windowWidth = res.windowWidth;
    this.data.stv.offset = res.windowWidth * page;
    this.setData({
      stv: this.data.stv,
      activeTab: page
    });
    this.tabsCount = tabs.length;
    console.log(this.data.buyNowInfoMem)
    if (this.data.buyNowInfoMem.is_dada) {
      this.getDadafee();
    } else {
      if (page == 0) {
        this.setData({
          order_price: this.data.buyNowInfoMem.order_price,
          checked: false,
          isDikou: false
        })
      } else {
        this.setData({
          order_price: this.data.buyNowInfoMem.total_price,
          checked: false,
          isDikou: false
        })
      }
    }
  },

  handlerTabTap(e) {
    if (!this.data.buyNowInfoMem.is_delive && e.currentTarget.dataset.index == 0) {
      wx.showModal({
        title: '提示',
        content: this.data.buyNowInfoMem.message,
        showCancel: false
      })
      return;
    }
    this._updateSelectedPage(e.currentTarget.dataset.index);
  },

  getDistrictId: function(obj, aaa) {
    if (!obj) {
      return "";
    }
    if (!aaa) {
      return "";
    }
    return aaa;
  },
  bindPickerChange: function(e) {
    var that = this
    console.log('picker发送选择改变，携带值为', e.detail.value)
    if (e.detail.value == 0) {
      if (this.data.isDikou) {
        this.setData({
          pay_type: 'wechat',
          isDikou: false
        });
        wx.showModal({
          title: '提示',
          content: '使用账户余额抵扣不能选择余额支付！',
          showCancel: false
        })
        return;
      } else {
        this.setData({
          pay_type: 'credit'
        });
      }
    } else {
      this.setData({
        pay_type: 'wechat'
      });
    }

    var activeTab = that.data.activeTab;
    if (activeTab == 0) {
      var buyNowInfoMem = that.data.buyNowInfoMem;
      if (buyNowInfoMem.default_address.contact_address == undefined) {
        wx.showModal({
          title: '提示',
          content: '请先选择配送地址！',
          showCancel: false
        })
        return
      }
      var peisong_jingwei = buyNowInfoMem.default_address.contact_address_jingwei;
      var shop_id = buyNowInfoMem.shop_id;
      var service = 'Product.CheckPeisongLength';
      var sign = md5.md5(peisong_jingwei + service + shop_id);
      wx.request({
        url: app.globalData.serviceUrl + service,
        header: {
          'Content-Type': 'json'
        },
        data: {
          sign: sign,
          shop_id: shop_id,
          peisong_jingwei: peisong_jingwei,
        },
        success: function (res) {
          var result = res.data.data;
          if (result.code == 0) {
            if (result.info.is_peisong == 1) {
              wx.showModal({
                title: '提示',
                content: '不在配送范围内',
                success: function (res) {
                  wx.navigateTo({
                    url: "/pages/select-address/index"
                  })
                },
                showCancel: false
              })
              return;
            } else {
              //配送订单支付
              if (e.detail.value == 0) {
                //余额支付
                var service = 'User.GetMoneyInfo';
                var user_id = app.globalData.userId;
                var open_id = app.globalData.openId;
                var sign = md5.md5(open_id + service + user_id);
                wx.request({
                  url: app.globalData.serviceUrl + service,
                  header: {
                    'Content-Type': 'json'
                  },
                  data: {
                    sign: sign,
                    user_id: user_id,
                    open_id: open_id
                  },
                  success: function (resa) {
                    wx.showModal({
                      title: '提示',
                      content: '可用余额' + resa.data.data.info.moen_recharge + '元',
                      confirmText: '立即支付',
                      success: function (res) {
                        if (res.confirm) {
                          that.commitOrder();
                        } else if (res.cancel) {
                          wx.showToast({
                            title: '取消支付',
                            icon: 'success',
                            duration: 2000
                          })
                          return;
                        }
                      }
                    })
                  }
                })
              } else {
                //微信支付
                that.commitOrder();
              }
            }
          }
        },
        fail: function () {
          //请求超时提示
          wx.showModal({
            title: '提示',
            content: '网络超时',
            showCancel: false
          })
          return;
        }
      })
    } else {
      //自取订单支付
      if (e.detail.value == 0) {
        //余额支付
        var service = 'User.GetMoneyInfo';
        var user_id = app.globalData.userId;
        var open_id = app.globalData.openId;
        var sign = md5.md5(open_id + service + user_id);
        wx.request({
          url: app.globalData.serviceUrl + service,
          header: {
            'Content-Type': 'json'
          },
          data: {
            sign: sign,
            user_id: user_id,
            open_id: open_id
          },
          success: function (resa) {
            wx.showModal({
              title: '提示',
              content: '可用余额' + resa.data.data.info.moen_recharge + '元',
              confirmText: '立即支付',
              success: function (res) {
                if (res.confirm) {
                  that.commitOrder();
                } else if (res.cancel) {
                  wx.showToast({
                    title: '取消支付',
                    icon: 'success',
                    duration: 2000
                  })
                  return;
                }
              }
            })
          }
        })
      } else {
        //微信支付
        that.commitOrder();
      }
    }

  },
  noteInput: function(e) {
    this.setData({
      note: e.detail.value
    })
  },
  commitOrder: function() {
    var that = this
    var buyNowInfoMem = that.data.buyNowInfoMem;
    var isDikou = that.data.isDikou;
    var cost = (isDikou == true) ? that.data.cost : 0.00;
    var discount = (isDikou == true) ? that.data.discount : 0.00;
    var delive_address = '';
    if (that.data.activeTab == 0) {
      delive_address += buyNowInfoMem.default_address.contact_name;
      delive_address += buyNowInfoMem.default_address.contact_sex;
      delive_address += buyNowInfoMem.default_address.contact_tel;
      delive_address += buyNowInfoMem.default_address.contact_address;
      delive_address += buyNowInfoMem.default_address.contact_menpai;
    }

    wx.showToast({
      title: '提交订单',
      icon: 'loading'
    })

    var activeTab = that.data.activeTab;
    var delive_type = 1;
    if (activeTab == 0) {
      delive_type = 2;
    } else {
      delive_type = 1;
    }
    var is_dada = that.data.is_dada;
    var delive_jingwei = '';
    var deliveryNo = '';
    if (is_dada == 0) {   
      if (that.data.jingwei != undefined){
        var delive_jingweiarray = that.data.jingwei.split(",");
        delive_jingwei = delive_jingweiarray[0] + ',' + delive_jingweiarray[1];
        deliveryNo = that.data.deliveryNo;
      }
    }

    var goumai_num = 1;
    var note = that.data.note;
    var openid = app.globalData.openId;
    var order_id = buyNowInfoMem.order_id;
    var order_num = buyNowInfoMem.order_num;
    var shop_id = buyNowInfoMem.shop_id;
    //包装费
    var canhe_money = String(buyNowInfoMem.canhe_money);
    
    
    var service = 'Order.CommitOrderMany';
    if (that.data.pay_type == 'wechat') {
      var total_price = ((activeTab == 0) ? buyNowInfoMem.order_price : buyNowInfoMem.order_price) - cost;
    } else {
      var total_price = ((activeTab == 0) ? buyNowInfoMem.order_price : buyNowInfoMem.order_price);
    }
    total_price = total_price.toFixed(2)//对计算结果进行两位小数处理

    //减免/配送
    if (activeTab == 0) { 
      var jianmian_money = that.data.reduceMone;
      var peisong_money = buyNowInfoMem.delive_fee;
    } else {
      var jianmian_money = that.data.reduceMone;
      var peisong_money = 0;
    }
    var type = 1;
    var user_id = app.globalData.userId;
    var user_tel = buyNowInfoMem.user_tel;
    var sign = md5.md5(canhe_money + '' + cost + delive_address + delive_jingwei + delive_type + deliveryNo + discount + goumai_num + jianmian_money + note + openid + order_id + order_num + peisong_money + service + shop_id + total_price + type + user_id + user_tel);
    wx.request({
      url: app.globalData.serviceUrl + 'Order.CommitOrderMany',
      header: {
        'Content-Type': 'json'
      },
      data: {
        delive_jingwei: delive_jingwei,
        deliveryNo: deliveryNo,
        cost: cost,
        delive_address: delive_address,
        delive_type: delive_type,
        discount: discount,
        goumai_num: goumai_num,
        openid: openid,
        order_id: order_id,
        order_num: order_num,
        peisong_money: peisong_money,
        shop_id: shop_id,
        note: note,
        total_price: total_price,
        type: type,
        user_id: user_id,
        user_tel: user_tel,
        canhe_money: canhe_money,
        jianmian_money: jianmian_money,
        sign: sign,
      },
      success: function(res) {
        var result = res.data.data;
        if (result.code != 0) {
          wx.hideToast()
          wx.showModal({
            title: '失败',
            content: '下单失败',
            showCancel: false
          })
          return;
        }
        var client = 'wxa';
        // var isDikou = that.data.isDikou;
        // var cost = (isDikou == true) ? that.data.dikou : 0.00;
        var total = ((activeTab == 0) ? buyNowInfoMem.order_price : that.data.order_price);
        var openid = app.globalData.openId;
        var order_id = result.info.order_id;
        var order_num = result.info.order_num;
        var service = 'Pay.Index';
        console.log(that.data.pay_type);
        var pay_type = that.data.pay_type;
        var user_id = app.globalData.userId;
        var sign = md5.md5(client + cost + openid + order_id + order_num + service + pay_type + user_id);
        wx.request({
          url: app.globalData.serviceUrl + 'Pay.Index',
          header: {
            'Content-Type': 'json'
          },
          data: {
            client: client,
            cost: cost,
            openid: openid,
            order_id: order_id,
            order_num: order_num,
            type: pay_type,
            user_id: user_id,
            sign: sign,
          },
          success: function(res) {
            var result = res.data.data;
            if (result.code != 0) {
              if (that.data.pay_type == 'wechat') {
                wx.hideToast()
                wx.showModal({
                  title: '失败',
                  content: "支付失败",
                  showCancel: false
                })
                return;
              }else{
                wx.hideToast()
                wx.showModal({
                  title: '失败',
                  content: "可用支付余额不足",
                  showCancel: false
                })
                return;
              }
            }
            if (that.data.pay_type == 'wechat') {
              wx.hideToast()
              wxpay.wxpay(app, total, order_num, "/pages/ucenter/order-list/index", 'product', order_id, md5);
            } else {
              setTimeout(function() {
                wx.hideToast()
                wx.navigateTo({
                  url: "/pages/ucenter/order-list/index"
                })
              }, 1000)
            }
          },
          complete: function(res) {
            wx.hideToast()
            console.log(res);
          },
        })
      },
      complete: function(res) {
        wx.hideToast()
        console.log(res);
      },
    })
  },
  addAddress: function() {
    wx.navigateTo({
      url: "/pages/address-add/index"
    })
  },
  selectAddress: function() {
    this.setData({
      reduceMone: 0,
      isType: true
    })
    wx.navigateTo({
      url: "/pages/select-address/index"
    })
  },
  bindChangeCoupon: function(e) {
    const selIndex = e.detail.value[0] - 1;
    if (selIndex === -1) {
      this.setData({
        youhuijine: 0,
        curCoupon: null
      });
      return;
    }

    this.setData({
      youhuijine: this.data.coupons[selIndex].money,
      curCoupon: this.data.coupons[selIndex]
    });
  },

  checkboxChange: function(e) {
    var buyNowInfoMem = this.data.buyNowInfoMem;
    var dikou = this.data.dikou;
    var activeTab = this.data.activeTab;
    if (e.detail.value[0] == 1) {
      console.log(e.detail.value[0]);
      if (activeTab == 0) {
        var order_price = buyNowInfoMem.order_price - dikou;
      } else {
        var order_price = buyNowInfoMem.total_price - dikou;
      }
      this.setData({
        order_price: order_price.toFixed(2),//对计算结果进行两位小数处理
        isDikou: true
      })
    } else {
      if (activeTab == 0) {
        var order_price = buyNowInfoMem.order_price;
      } else {
        var order_price = buyNowInfoMem.total_price;
      }
      this.setData({
        order_price: order_price,
        isDikou: false
      })
    }
    console.log(this.data)
  },

  getlod: function() {
    var that = this;
    var service = 'User.CheckLand';
    var open_id = app.globalData.openId;
    var user_id = app.globalData.userId;
    var sign = md5.md5(open_id + service + user_id);
    wx.request({
      url: app.globalData.serviceUrl + service,
      header: {
        'Content-Type': 'json'
      },
      data: {
        sign: sign,
        user_id: user_id,
        open_id: open_id,
      },
      success: (res) => {
        var result = res.data.data;
        if (result.code == 0) {
          if (result.info == 0) {
            app.globalData.userTel = '';
            app.globalData.userId = '';
            app.globalData.openId = '';
            app.globalData.pageFlag = false;
            wx.clearStorage();
            wx.navigateTo({
              url: "/pages/login/index"
            })
          }
        } else {
          app.globalData.userTel = '';
          app.globalData.userId = '';
          app.globalData.openId = '';
          app.globalData.pageFlag = false;
          wx.clearStorage();
          wx.navigateTo({
            url: "/pages/login/index"
          })
        }
      }
    })
  },
})